﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Booking.WPServiceData;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace Booking
{
    public partial class Page1 : PhoneApplicationPage
    {
        
        menu _menu;
        public Page1()
        {
            InitializeComponent();
            
            
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            int id = int.Parse(NavigationContext.QueryString["id"]);
            ServiceSoapClient service = new ServiceSoapClient();
            service.GetMenuByIdCompleted += new EventHandler<GetMenuByIdCompletedEventArgs>(fillData);
            service.GetMenuByIdAsync(id);
            base.OnNavigatedTo(e);
        }

        void fillData(object sender, GetMenuByIdCompletedEventArgs e)
        {
            _menu = e.Result;
            if (_menu != null)
            {
                detailImage.Source = new BitmapImage(new Uri(lib.DefinesClass.ipService + _menu.images , UriKind.RelativeOrAbsolute));
                tblTenMonAn.Text = _menu.name;
                tblBody.Text = _menu.description.Trim();
                gia.Text = "Giá: " + _menu.price.ToString() + "VND";
             }
        }

        private void btndatmon_Click_1(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Orderpage.xaml?id=" + _menu.id, UriKind.Relative));
        }

       

     
    }
}